﻿using System;
using System.ComponentModel;
using SQLite;


namespace Cashbook.Models
{
    [Table("Bills")]
    public class Bill: INotifyPropertyChanged
    {
		private int _id;
		[PrimaryKey, AutoIncrement]
		public int Id
		{
			get
			{
				return _id;
			}
			set
			{
				this._id = value;
				OnPropertyChanged(nameof(Id));
			}
		}

		private string _title;
		[NotNull]
		[MaxLength(50)]
		public string Title
		{
			get
			{
				return _title;
			}
			set
			{
				this._title = value;
				OnPropertyChanged(nameof(Title));
			}
		}

		private int _customerId;
		[NotNull]	
		public int CustomerId
		{
			get
			{
				return _customerId;
			}
			set
			{
				this._customerId = value;
				OnPropertyChanged(nameof(CustomerId));
			}
		}


		private int _amount;
		[NotNull]
		public int Amount
		{
			get
			{
				return _amount;
			}
			set
			{
				this._amount = value;
				OnPropertyChanged(nameof(Amount));
			}
		}


        private bool _isPayed;
		[NotNull]
        public bool IsPayed
		{
			get
			{
				return _isPayed;
			}
			set
			{
				this._isPayed = value;
				OnPropertyChanged(nameof(IsPayed));
			}
		}

        private DateTime _addedDate;
		[NotNull]
		public DateTime AddedDate
		{
			get
			{
				return _addedDate;
			}
			set
			{
				this._addedDate = value;
				OnPropertyChanged(nameof(AddedDate));
			}
		}


  //      public string AddedDateShow{
  //          get{
  //              return string.Format("{0:yy-MM-dd}", AddedDate);
  //          }
  //      }

  //      public string AmountEdited
		//{
		//	get
		//	{
		//		return string.Format("{0:C2}", Amount);
		//	}
		//}

		public event PropertyChangedEventHandler PropertyChanged;
		private void OnPropertyChanged(string propertyName)
		{
			this.PropertyChanged?.Invoke(this,
			  new PropertyChangedEventArgs(propertyName));
		}

    }
}
